#pragma once


#include <memory>
#include "Containers/Containers.h"
#include "ScriptCompiler/ScriptFileContext.h"
#include "Path/Path.h"

#include "Output/Console.h"
#include "CompileResult.h"

class CScriptToken;
class CTypeNode;
struct SDecoratedTypeDescription;
class CScriptFileContext;
class CExpressionNode;
class CNamespaceDescription;
class CTypeDescription;

class CCompilerContext
{
public:

    TMap<SPath,std::shared_ptr<CScriptFileContext>> ScriptFiles;
    
    SErrorInfo ErrorInfo;

    static CString CreatePositionInfo(std::shared_ptr<CScriptFileContext> File, const SScriptFilePosition& PositionInFile );
    
    
    
    struct SErrorMessage
    {
        uint64_t ErrorCode=0; //code of Error, for convenient to find error in compiler
        uint64_t LineIndex=0;
        uint64_t ColumnIndex=0;
        uint64_t CharNum=0;
        CString ErrorMessage;
        SPath File;
        bool bIsWarning=false;
    }; 

    void RaiseError(const SErrorMessage& ErrorMessage);
    
    
    void RaiseError(uint64_t ErrorCode,const SPath& File , const SScriptFilePosition& PositionInFile , const CString & InErrorMessage,bool bIsWarning=false);
    void RaiseError(uint64_t ErrorCode,const SPath& File , std::shared_ptr<CScriptToken> InToken     , const CString & InErrorMessage,bool bIsWarning=false);
    void RaiseError(uint64_t ErrorCode,const SPath& File , const CString & InErrorMessage,bool bIsWarning=false);


    std::shared_ptr<CNamespaceDescription> GlobalNamespace;

    TVector<std::shared_ptr<CTypeDescription>> ScriptClasses;

};